﻿//#ifndef INSTRUCTIONTURNTABLEPOWERON_H
//#define INSTRUCTIONTURNTABLEPOWERON_H

#pragma once
#include <QObject>

#include "ScriptInstruction.h"

class InstructionTurnTablePowerOn :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner= Q_NULLPTR;
  TurnTableCodec* turnTableCodec = Q_NULLPTR;
  TurnTableRunningStateManager* turnTableRunningStateManager = Q_NULLPTR;
public:
  InstructionTurnTablePowerOn()
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    turnTableCodec = ScriptInstruction::getTurnTableCodec();
    turnTableRunningStateManager = ScriptInstruction::getTurnTableRunningStateManager();
    instructionFlag = Instruction_TurnTable_PowerOn;
  }
  ~InstructionTurnTablePowerOn()
  {}
public:
  void run()override
  {
    turnTableCodec->sendInstruction(TurnTableCodec::TurnTable_PowerOn, 0, 0, 0);
    StateChecker<TurnTableCodec::TurnTablePowerSupplyState, TurnTableRunningStateManager>::next_ifConditionReached(&TurnTableRunningStateManager::getState_turnTable_powerSupply, turnTableRunningStateManager, TurnTableCodec::State_PowerOn, scriptRunner->getInterval_turnTableOperationTimeOut(),scriptRunner);
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    return savingData;
  }
};
